package com.example.demo.domain.vo.front;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class ResBody<T> {
    @ApiModelProperty(value = "状态码")
    private int sysCode;
    @ApiModelProperty(value = "返回信息")
    private String msg;
    @ApiModelProperty(value = "返回的数据")
    private T data;

    public ResBody(int sysCode, String msg, T data) {
        this.sysCode = sysCode;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResBody<T> success(String msg, T data) {
        return new ResBody<>(200, msg, data);
    }

    public static <T> ResBody<T> success(T data) {
        return new ResBody<>(200, "success", data);
    }

    public static <T> ResBody<T> success() {
        return new ResBody<>(200, "成功", null);
    }

    public static <T> ResBody<T> fail() {
        return new ResBody<>(400, "请求", null);
    }

    public static <T>  ResBody<T> fail(String msg) {
        return new ResBody<>(400, msg, null);
    }
}
